<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sessionStorage</title>
</head>
<body>
    <h1>这是sessionStorage</h1>
    <button onclick="addData()">点我添加一个数据</button><br>
    <button onclick="getData()">点我查询一个数据</button><br>
    <button onclick = "deleteData()">点我删除一个数据</button><br>
    <button onclick="clearData()">点我清除所有的这是sessionStorage数据</button>
</body>
<script>
    function addData(){
        sessionStorage.setItem("name","张三");
        sessionStorage.setItem("age",18);
        sessionStorage.setItem("sex","男");
        sessionStorage.setItem("address","武汉");
        let obj = {
            schoolName:"华中科技大学",
            address:"武汉"
        }
        sessionStorage.setItem("school",JSON.stringify(obj))
    }
    function deleteData(){
        sessionStorage.removeItem("name");
        alert("删除数据成功")
    }
    function updateData(){
        sessionStorage.setItem("name","王五");
        alert("更新数据成功")
    }
    function clearData(){
        sessionStorage.clear();
        alert("清除数据成功")
    }
</script>
</html>